package com.chenglu.android.restaurant.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.FragmentTransaction;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.chenglu.android.R;
import com.chenglu.android.restaurant.bean.GoodscategorylisBean;

import java.util.List;

/**
 * @author: lyj
 * @Created: by Copyright 2023 3 Guangzhou Hongma Technology Co., Ltd. All rights reserved.
 * @Description：满减
 */
public class ShopCategoryGoodItemAdapter extends BaseQuickAdapter<GoodscategorylisBean.DataBean.GoodsVOListBean, BaseViewHolder> {

    Context mContext;
    List<GoodscategorylisBean.DataBean.GoodsVOListBean> data;

    public ShopCategoryGoodItemAdapter(Context context, @Nullable List<GoodscategorylisBean.DataBean.GoodsVOListBean> data) {
        super(R.layout.item_shopcategory_good_item, data);
        this.mContext = context;
        this.data=data;
    }


    @Override
    protected void convert(@NonNull BaseViewHolder helper, GoodscategorylisBean.DataBean.GoodsVOListBean item) {
        ImageView imageView = helper.getView(R.id.iv_item_src);
        Glide.with(mContext).load(item.getGoodsImg()).into(imageView);
        helper.setText(R.id.tv_item_title, item.getGoodsName());
        helper.setText(R.id.tv_item_des, "销量"+item.getSalesAmount());
        helper.setText(R.id.tv_shop_price, item.getGoodsPrice()+"");
        if (item.getIsSpec()==1){
            helper.setVisible(R.id.tv_shop_add,true);
            helper.setGone(R.id.iv_shop_add,false);
        }else {
            helper.setVisible(R.id.iv_shop_add,true);
            helper.setGone(R.id.tv_shop_add,false);
        }
//        if ( helper.getLayoutPosition()==data.size()-1){
//            helper.setGone(R.id.view_bottom,true);
//        }else {
//            helper.setGone(R.id.view_bottom,false);
//        }

        helper.addOnClickListener(R.id.iv_shop_add);
        helper.addOnClickListener(R.id.tv_shop_add);

//        if (TextUtils.isEmpty(item.getPic())) {
//            helper.setGone(R.id.tv_item_shopcategory_good, true);
//            helper.setText(R.id.tv_item_shopcategory_good, item.getCategoryName());
//            helper.setGone(R.id.iv_item_shopcategory_good, false);
//        } else {
//            helper.setGone(R.id.tv_item_shopcategory_good, false);
//            helper.setGone(R.id.iv_item_shopcategory_good, true);
//            ImageView imageView = helper.getView(R.id.iv_item_shopcategory_good);
//            Glide.with(mContext).load(item.getPic()).into(imageView);
//        }


    }

}
